import { authProvider } from '@boticord/auth'
import { BotClientModule } from '@boticord/bot-client'
import { StartupModule } from '@boticord/startup'
import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { BotController } from './controllers/bot.controller'
import { CommentController } from './controllers/comment.controller'
import { ServerController } from './controllers/server.controller'
import { ServersService } from './services/servers.service'
import { BotsService } from './services/bots.service'
import { ValidationUtil } from './validation.util'
import { UpsService } from './services/ups.service'
import { UpsController } from './controllers/ups.controller'
import { ScheduleModule } from '@nestjs/schedule'
import { ResourcesService } from './services/resources.service'
import { ReportsService } from './services/reports.service'
import { ReportController } from './controllers/report.controller'
import { CommentsService } from './services/comments.service'
import { ReindexController } from './controllers/reindex.controller'
import { BoostsService } from './services/boosts.service'
import { ChatController } from './controllers/chat.controller'

@Module({
  imports: [
    ScheduleModule.forRoot(),
    StartupModule.forRoot('ResourcesService'),
    BotClientModule.forRootAsync({
      useFactory: (config: ConfigService) => ({
        natsServers: config.getOrThrow('NATS_SERVERS').split(','),
      }),
      inject: [ ConfigService ],
      imports: [ ConfigModule ],
    }),
  ],
  controllers: [
    CommentController, 
    ServerController, 
    BotController, 
    UpsController, 
    ReportController,
    ReindexController,
    ChatController,
  ],
  providers: [ 
    authProvider,
    ServersService,
    ValidationUtil,
    BotsService,
    UpsService,
    ResourcesService,
    ReportsService,
    CommentsService,
    BoostsService,
  ],
})
export class AppModule {}